﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using QLTV_Public;

namespace QLTV_Data
{
   public class DonVi_Data
    {
       KetNoiCSDL_Data kn = new KetNoiCSDL_Data();
       public DataTable TaoBang(string sql)
       {
           return kn.taobang(sql);
       }
       public DataTable LayDuLieu()
       {
           return kn.LayDuLieu("Load_DonVi");
       }
       public int Insert(DonVi_Public maDonVi,DonVi_Public tenDonVi,DonVi_Public ghiChu)
       {
           int paramater=3;
           string[] name = new string[paramater];
           object[] values = new object[paramater];
           name[0] = "@MaDonVi";
           values[0] = maDonVi.MaDonVi;
           name[1] = "@TenDonVi";
           values[1] = tenDonVi.TenDonVi;
           name[2] = "@GhiChu";
           values[2] = ghiChu.GhiChu;
           return kn.update("Insert_DonVi", name, values, paramater);

       }
       public int Update(DonVi_Public maDonVi, DonVi_Public tenDonVi, DonVi_Public ghiChu)
       {
           int paramater = 3;
           string[] name = new string[paramater];
           object[] values = new object[paramater];
           name[0] = "@MaDonVi";
           values[0] = maDonVi.MaDonVi;
           name[1] = "@TenDonVi";
           values[1] = tenDonVi.TenDonVi;
           name[2] = "@GhiChu";
           values[2] = ghiChu.GhiChu;
           return kn.update("Update_DonVi", name, values, paramater);

       }
       public int Delete(DonVi_Public maDonVi)
       {
           int paramater = 1;
           string[] name = new string[paramater];
           object[] values = new object[paramater];
           name[0] = "@MaDonVi";
           values[0] = maDonVi.MaDonVi;
           return kn.update("Delete_DonVi", name, values, paramater);

       }
    }
}
